package lab03;

import java.sql.*;

public class TopPassword {
    public static void main(String[] args) throws SQLException {
        Connection connection = DBCPDatasource.getConnection();
        String sql="select password,count(password) from db_csdn.csdn group by password order by count(password) desc";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        int i=0;
        while (resultSet.next()) {
            System.out.println(resultSet.getString("password") +"次数:"+ resultSet.getInt("count(password)"));
            i++;

            if(i==10)
            break;

        }
    }
}
/*
123456789次数:235024
12345678次数:212751
11111111次数:76346
dearbook次数:46054
00000000次数:34952
123123123次数:19986
1234567890次数:17791
88888888次数:15033
111111111次数:6995
147258369次数:5966
*/